package com.otp.model.test.template;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "attribute_sets")
public class AttributeSet implements Serializable{

	private static final long serialVersionUID = 1;
	private Long objectId;
	private String name;
	private String description;
    private List<Attribute> atts = new ArrayList<Attribute>();

	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "object_id", unique = true, nullable = false)
	public Long getObjectId() {
		return objectId;
	}	
	public void setObjectId(Long objectId) {
		this.objectId = objectId;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "description")
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(
            name = "att2set",
            joinColumns = {@JoinColumn(name = "id_set")},
            inverseJoinColumns = @JoinColumn(name = "id_att")
    )
    public List<Attribute> getAtts() {
        return atts;
    }
    
    public void setAtts(List<Attribute> atts) {
        this.atts = atts;
    }
}
